#ifndef WINSOCK_PROXY_H_
#define WINSOCK_PROXY_H_

#include <winsock2.h>
#include <ws2tcpip.h>

typedef SOCKET (*accept_proxy_t)         ( SOCKET, struct sockaddr*, int* );
typedef int    (*closesocket_proxy_t)    ( SOCKET );
typedef int    (*bind_proxy_t)           ( SOCKET, struct sockaddr*, int );
typedef int    (*connect_proxy_t)        ( SOCKET, struct sockaddr*, int );
typedef void   (*freeaddrinfo_proxy_t)   ( ADDRINFOA*);
typedef void   (*FreeAddrInfoW_proxy_t)  ( ADDRINFOW*);
typedef int    (*getaddrinfo_proxy_t)    ( PCSTR, PCSTR, const ADDRINFOA*, PADDRINFOA* );
typedef int    (*GetAddrInfoW_proxy_t)   ( PCWSTR, PCWSTR, const ADDRINFOW*, PADDRINFOW* );
typedef int    (*getpeername_proxy_t)    ( SOCKET, struct sockaddr*, int* );
typedef int    (*getsockname_proxy_t)    ( SOCKET, struct sockaddr*, int* );
typedef int    (*ioctlsocket_proxy_t)    ( SOCKET, long, u_long* );
typedef int    (*getsockopt_proxy_t)     ( SOCKET, int, int, int*, int* );
typedef int    (*listen_proxy_t)         ( SOCKET, int );
typedef int    (*recv_proxy_t)           ( SOCKET, char*, int, int );
typedef int    (*recvfrom_proxy_t)       ( SOCKET, char*, int, int, struct sockaddr*, int* );
typedef int    (*select_proxy_t)         ( int, fd_set*, fd_set*, fd_set*, const struct timeval* );
typedef int    (*send_proxy_t)           ( SOCKET, const char*, int, int );
typedef int    (*sendto_proxy_t)         ( SOCKET, const char*, int, int, const struct sockaddr*, int );
typedef int    (*shutdown_proxy_t)       ( SOCKET, int );
typedef SOCKET (*socket_proxy_t)         ( int, int, int );
typedef int    (*setsockopt_proxy_t)     ( SOCKET, int, int, const char*, int );
typedef int    (*WSACleanup_proxy_t)     ( void );
typedef int    (*__WSAFDIsSet_proxy_t)   ( SOCKET, fd_set* );
typedef int    (*WSAGetLastError_proxy_t)( void );
typedef void   (*WSASetLastError_proxy_t)( int );
typedef SOCKET (*WSASocket_proxy_t)      ( int, int, int, LPWSAPROTOCOL_INFO, GROUP, DWORD );
typedef int    (*WSAStartup_proxy_t)     ( WORD, LPWSADATA );
//typedef int    (*WSAStartup_proxy_t)     ( WORD, LPWSADATA );

extern WSASetLastError_proxy_t pTrueWSASetLastError;
extern freeaddrinfo_proxy_t    pTrueFreeaddrinfo;

SOCKET accept_proxy ( 
    __in  SOCKET           s,
    __out struct sockaddr* addr,
    __inout int*           addrlen
    );

int closesocket_proxy ( 
    __in SOCKET s
    );

int bind_proxy ( 
    __in SOCKET           s,
    __in struct sockaddr* addr,
    __in int              addrlen
    );

int connect_proxy (
    __in SOCKET           s,
    __in struct sockaddr* addr,
    __in int              addrlen
    );

void freeaddrinfo_proxy (__in ADDRINFOA* ai);

void FreeAddrInfoW_proxy (__in ADDRINFOW* ai);

int getaddrinfo_proxy (
    __in_opt  PCSTR             pNodeName,
    __in_opt  PCSTR             pServiceName,
    __in_opt  const ADDRINFOA*  pHints,
    __out     PADDRINFOA*       ppResult
    );

int GetAddrInfoW_proxy (
    __in_opt  PCWSTR             pNodeName,
    __in_opt  PCWSTR             pServiceName,
    __in_opt  const ADDRINFOW*   pHints,
    __out     PADDRINFOW*        ppResult
    );

int getpeername_proxy ( 
    __in  SOCKET           s,
    __out struct sockaddr* addr,
    __inout int*           addrlen
    );

int getsockname_proxy ( 
    __in  SOCKET           s,
    __out struct sockaddr* addr,
    __inout int*           addrlen
    );

int ioctlsocket_proxy ( 
    __in     SOCKET  s,
    __in     long    cmd,
    __inout  u_long* argp
    );

int getsockopt_proxy ( 
    __in    SOCKET s,
    __in    int    level,
    __in    int    optname,
    __out   char*  optval,
    __inout int*   optlen
    );

int listen_proxy ( 
    __in SOCKET s,
    __in int    backlog
    );

int recv_proxy ( 
    __in  SOCKET s,
    __out char*  buf,
    __in  int    len,
    __in  int    flags
    );

int recvfrom_proxy ( 
    __in  SOCKET s,
    __out char*  buf,
    __in  int    len,
    __in  int    flags,
    __out       struct sockaddr* from,
    __inout_opt int*             fromlen
    );

int select_proxy (
    __in    int     nfds,
    __inout fd_set* readfds,
    __inout fd_set* writefds,
    __inout fd_set* exceptfds,
    __in    const struct timeval* timeout
    );

int send_proxy (
    __in  SOCKET      s,
    __in  const char* buf,
    __in  int         len,
    __in  int         flags
    );

int sendto_proxy (
    __in  SOCKET      s,
    __in  const char* buf,
    __in  int         len,
    __in  int         flags,
    __in  const struct sockaddr* to,
    __in  int         tolen
    );

int shutdown_proxy (
    __in  SOCKET s,
    __in  int how
    );

SOCKET socket_proxy (
    __in  int af,
    __in  int type,
    __in  int protocol
    );

int setsockopt_proxy (
    __in  SOCKET s,
    __in  int level,
    __in  int optname,
    __in  const char *optval,
    __in  int optlen
    );

int WSACleanup_proxy ( void );

int __WSAFDIsSet_proxy (
    SOCKET fd,
    fd_set *set
    );

int WSAGetLastError_proxy ( void );

void WSASetLastError_proxy (
    __in  int iError
    );

SOCKET WSASocket_proxy (
    __in  int                af,
    __in  int                type,
    __in  int                protocol,
    __in  LPWSAPROTOCOL_INFO lpProtocolInfo,
    __in  GROUP              g,
    __in  DWORD              dwFlags
    );

int WSAStartup_proxy (
    __in   WORD wVersionRequested,
    __out  LPWSADATA lpWSAData
);

#include "..\..\src\WinsockProxyLib\vcCommunication.h"

#endif /* WINSOCK_PROXY_H_ */
